home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / SONIDO / IT105 / ITTECH.DOC < prev    next >
Encoding:
Text File  |  1996-02-23  |  16.8 KB  |  360 lines

  1.  
  2.                              Impulse Header Layout
  3.  
  4.         0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
  5.       ┌───┬───┬───┬───┬───────────────────────────────────────────────┐
  6. 0000: │'I'│'M'│'P'│'M'│ Song Name, max 26 characters, includes NULL   │
  7.       ├───┴───┴───┴───┴───────────────────────────────────────┬───┬───┤
  8. 0010: │.......................................................│ x │ x │
  9.       ├───────┬───────┬───────┬───────┬───────┬───────┬───────┼───┴───┤
  10. 0020: │OrdNum │InsNum │SmpNum │PatNum │ Cwt/v │ Cmwt  │ Flags │Special│
  11.       ├───┬───┼───┬───┼───┬───┼───────┼───────┴───────┼───┬───┼───┬───┤
  12. 0030: │GV │MV │IS │IT │Sep│(0)│MsgLgth│Message Offset │ x │ x │ x │ x │
  13.       ├───┴───┴───┴───┴───┴───┴───────┴───────────────┴───┴───┴───┴───┤
  14. 0040: │ Chnl Pan (64 bytes)...........................................│
  15.       ├───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┤
  16.  
  17.       ├───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┤
  18. 0080: │ Chnl Vol (64 bytes)...........................................│
  19.       ├───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┤
  20.  
  21.       ├───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┤
  22. 00C0: │ Orders, Length = OrdNum                                       │
  23.       ├───────────────────────────────────────────────────────────────┤
  24. xxxx: │ 'Long' Offset of instruments, Length = InsNum*4 (1)           │
  25.       ├───────────────────────────────────────────────────────────────┤
  26. xxxx: │ 'Long' Offset of samples headers, Length = SmpNum*4 (2)       │
  27.       ├───────────────────────────────────────────────────────────────┤
  28. xxxx: │ 'Long' Offset of patterns, Length = PatNum*4 (3)              │
  29.       └───────────────────────────────────────────────────────────────┘
  30.  
  31.       (1) Offset = 00C0h+OrdNum
  32.       (2) Offset = 00C0h+OrdNum+InsNum*4
  33.       (3) Offset = 00C0h+OrdNum+InsNum*4+SmpNum*4
  34.  
  35.         Note that if the (long) offset to a pattern = 0, then the
  36.         pattern is assumed to be a 64 row empty pattern.
  37.  
  38.       Cwt:      Created with tracker.
  39.                  Impulse Tracker y.xx = 0yxxh
  40.       Cmwt:     Compatible with tracker with version greater than value.
  41.       OrdNum:   Number of orders in song.
  42.       InsNum:   Number of instruments in song
  43.       SmpNum:   Number of samples in song
  44.       PatNum:   Number of patterns in song
  45.       Flags:    Bit 0: On = Stereo, Off = Mono
  46.                 Bit 1: Vol0MixOptimizations - If on, no mixing occurs if
  47.                        the volume at mixing time is 0 (redundant v1.04+)
  48.                 Bit 2: On = Use instruments, Off = Use samples.
  49.                 Bit 3: On = Linear slides, Off = Amiga slides.
  50.       Special:  Bit 0: On = song message attached.
  51.                        Song message:
  52.                         Stored at offset given by "Message Offset" field.
  53.                         Length = MsgLgth.
  54.                         NewLine = 0Dh (13 dec)
  55.                         EndOfMsg = 0
  56.                 Bits 1-15: Undefined.
  57.  
  58.       GV:       Global volume. (0->128) All volumes are adjusted by this
  59.       MV:       Mix volume (0->128) During mixing, this value controls
  60.                 the magnitude of the wave being mixed.
  61.       IS:       Initial Speed of song.
  62.       IT:       Initial Tempo of song
  63.       Sep:      Panning separation between channels (0->128, 128 is max sep.)
  64.       Chnl Vol: Volume for each channel. Ranges from 0->64
  65.       Chnl Pan: Each byte contains a panning value for a channel. Ranges from
  66.                  0 (absolute left) to 64 (absolute right). 32 = central pan,
  67.                  100 = Surround sound.
  68.                  +128 = disabled channel (notes will not be played, but note
  69.                                           that effects in muted channels are
  70.                                           still processed)
  71.       Orders:   This is the order in which the patterns are played.
  72.                  Valid values are from 0->199.
  73.                  255 = "---", End of song marker
  74.                  254 = "+++", Skip to next order
  75.  
  76.  
  77.                            Impulse Instrument Format
  78.  
  79.         0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
  80.       ┌───┬───┬───┬───┬───────────────────────────────────────────────┐
  81. 0000: │'I'│'M'│'P'│'I'│ DOS FileName (12345678.123)                   │
  82.       ├───┼───┼───┼───┼───┬───┬───┬───┬───────┬───┬───┬───────┬───┬───┤
  83. 0010: │00h│Flg│VLS│VLE│SLS│SLE│ x │ x │FadeOut│NNA│DNC│TrkVers│NoS│ x │
  84.       ├───┴───┴───┴───┴───┴───┴───┴───┴───────┴───┴───┴───────┴───┴───┤
  85. 0020: │ Instrument Name, max 26 bytes, includes NUL...................│
  86.       ├───────────────────────────────────────┬───┬───┬───┬───┬───┬───┤
  87. 0030: │.......................................│ x │ x │ x │ x │ x │ x │
  88.       ├───────────────────────────────────────┴───┴───┴───┴───┴───┴───┤
  89. 0040: │ Note-Sample/Keyboard Table, Length = 240 bytes................│
  90.       ├───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┤
  91.  
  92.       ├───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┤
  93. 0130: │ Volume envelope (200 bytes)...................................│
  94.       ├───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┤
  95.  
  96.                                       ├───┴───┴───┴───┴───┴───┴───┴───┤
  97. 01F8:                                 │ Node points (25x2 bytes)......│
  98.                                       └───────────────────────────────┘
  99.  
  100.         Total length of an instrument header is 554 bytes. But for practical
  101.         use in a player, it's better to load 504 bytes (up to 1F8h) into
  102.         memory, load the extra 50 bytes into a temporary buffer and look up the
  103.         node times (for VLS/VLE/SLS/SLE) during loadup (as opposed to during
  104.         playback).
  105.  
  106.       Flg:      Bit 0. On = Use volume envelope
  107.                 Bit 1. On = Use volume loop
  108.                 Bit 2. On = Use sustain volume loop
  109.       VLS:      Volume loop start (node number)
  110.       VLE:      Volume loop end (node number)
  111.       SLS:      Sustain loop start (node number)
  112.       SLE:      Sustain loop end (node number)
  113.       FadeOut:  Ranges between 0 and 64, but the fadeout "Count" is 512.
  114.                 See the Last section on how this works.
  115.                 Fade applied when:
  116.                 1) Note fade NNA is selected and triggered (by another note)
  117.                 2) Note off NNA is selected with no volume envelope
  118.                    or volume envelope loop
  119.                 3) Volume envelope end is reached
  120.  
  121.       DNC:      Duplicate note check (0 = Off, 1 = On)
  122.       NNA:      New note action:
  123.                         0 = Note cut
  124.                         1 = Note off
  125.                         2 = Note continue
  126.                         3 = Note fade
  127.  
  128.       TrkVers:  Tracker version used to save the instrument. This is only
  129.                 used in the instrument files.
  130.       NoS:      Number of samples associated with instrument. This is only
  131.                 used in the instrument files.
  132.  
  133.       Note-Sample/Keyboard Table.
  134.        Each note of the instrument is first converted to a sample number
  135.        and a note (C-0 -> B-9). These are stored as note/sample pairs
  136.        (note first, range 0->119 for C-0 to B-9, sample ranges from
  137.        1-99, 0=no sample)
  138.  
  139.        Volume envelope: Values from 0->64, 0FFh indicating end of envelope.
  140.        (after which note fade applies)
  141.  
  142.       Node data: Tick THEN magnitude
  143.  
  144.  
  145.  
  146.                              Impulse Sample Format
  147.  
  148.         0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
  149.       ┌───┬───┬───┬───┬───────────────────────────────────────────────┐
  150. 0000: │'I'│'M'│'P'│'S'│ DOS Filename (12345678.123)                   │
  151.       ├───┼───┼───┼───┼───────────────────────────────────────────────┤
  152. 0010: │00h│GvL│Flg│Vol│ Sample Name, max 26 bytes, includes NUL.......│
  153.       ├───┴───┴───┴───┴───────────────────────────────────────┬───┬───┤
  154. 0020: │.......................................................│ x │ x │
  155.       ├───────────────┬───────────────┬───────────────┬───────┴───┴───┤
  156. 0030: │ Length        │ Loop Begin    │ Loop End      │ C5Speed       │
  157.       ├───────────────┼───────────────┼───────────────┼───┬───┬───┬───┤
  158. 0040: │ SusLoop Begin │ SusLoop End   │ SamplePointer │ViS│ViD│ViR│ViT│
  159.       └───────────────┴───────────────┴───────────────┴───┴───┴───┴───┘
  160.  
  161. The cache file has the following pieces of information added on:
  162.  
  163.         0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
  164.       ┌───────────────┬───────┬───────┬───┬───────────────────────────┐
  165. 0050: │ File Size     │ Date  │ Time  │Fmt│...........................│
  166.       └───────────────┴───────┴───────┴───┴───────────────────────────┘
  167.  
  168.         Fmt. 0 = unchecked. 1 = directory, 2 = it sample, 3 = st sample
  169.  
  170.  
  171.       GvL:      Global volume for instrument, ranges from 0->64
  172.       Flg:      Bit 0. On = sample associated with header.
  173.                 Bit 1. On = 16 bit, Off = 8 bit.
  174.                 Bit 2. On = stereo, Off = mono. Stereo samples not supported yet
  175.                 Bit 3. Reserved
  176.                 Bit 4. On = Use loop
  177.                 Bit 5. On = Use sustain loop
  178.                 Bit 6. On = Ping Pong loop, Off = Forwards loop
  179.                 Bit 7. On = Ping Pong Sustain loop, Off = Forwards Sustain loop
  180.       Vol:      Default volume for instrument
  181.  
  182.       Length:   Length of sample in no. of samples NOT no. of bytes
  183.       LoopBeg:  Start of loop (no of samples in, not bytes)
  184.       Loop End: Sample no. AFTER end of loop
  185.       C5Speed:  Number of bytes a second for C-5 (ranges from 0->9999999)
  186.       SusLBeg:  Start of sustain loop
  187.       SusLEnd:  Sample no. AFTER end of sustain loop
  188.  
  189.       SmpPoint: 'Long' Offset of sample in file.
  190.  
  191.       ViS:      Vibrato Speed, ranges from 0->64
  192.       ViD:      Vibrato Depth, ranges from 0->64
  193.       ViT:      Vibrato waveform type.
  194.                         0=Sine wave
  195.                         1=Ramp down
  196.                         2=Square wave
  197.                         3=Random (speed is irrelevant)
  198.       ViR:      Vibrato Rate, rate at which vibrato is applied (0->64)
  199.  
  200.         The depth of the vibrato at any point is worked out in the following
  201.         way:
  202.           Every processing cycle, the following occurs:
  203.                 1) Mov AX, [SomeVariableNameRelatingToVibrato]
  204.                 2) Add AL, Rate
  205.                 3) AdC AH, 0
  206.                 4) AH contains the depth of the vibrato as a fine-linear slide.
  207.                 5) Mov [SomeVariableNameRelatingToVibrato], AX  ; For the next
  208.                                                                 ; cycle.
  209.  
  210.         For those that don't understand assembly, then the depth is
  211.         basically the running-sum of the rate divided by 256.
  212.  
  213.         Sample vibrato uses a table 256-bytes long
  214.  
  215.    Note: The sample load routine uses bytes the at 2Eh and 2Fh for conversion
  216.          flags! So DON'T write anything there!
  217.  
  218.          All samples are UNSIGNED (even 16-bit ones)
  219.  
  220.  
  221.  
  222.                              Impulse Pattern Format
  223.  
  224.         0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
  225.       ┌───────┬───────┬───┬───┬───┬───┬───────────────────────────────┐
  226. 0000: │Length │ Rows  │ x │ x │ x │ x │ Packed data................   │
  227.       ├───┬───┼───┬───┼───┼───┼───┼───┼───┬───┬───┬───┬───┬───┬───┬───┤
  228.  
  229.       Length:   Length of packed pattern, not including the 8 byte header
  230.                 Note that the pattern + the 8 byte header will ALWAYS
  231.                 be less than 64k
  232.       Rows:     Number of rows in this pattern (Ranges from 32->200)
  233.  
  234.       Patterns are unpacked by the following pseudocode...
  235.  
  236.       GetNextChannelMarker:
  237.         Read byte into channelvariable.
  238.         if(channelvariable = 0) then end of row
  239.         Channel = (channelvariable-1) & 63              ; Channel is 0 based.
  240.         if(channelvariable & 128) then read byte into maskvariable
  241.           else maskvariable = previousmaskvariable for current channel
  242.  
  243.         if(maskvariable & 1), then read note. (byte value)
  244.                 // Note ranges from 0->119 (C-0 -> B-9)
  245.                 // 255 = note off, 254 = notecut
  246.  
  247.         if(maskvariable & 2), then read instrument (byte value)
  248.                 // Instrument ranges from 1->99
  249.                 // Internally, 0 is used for no instrument, but should
  250.                 //  NEVER be found in a module...
  251.  
  252.         if(maskvariable & 4), then read volume/panning (byte value)
  253.                 // Volume ranges from 0->64
  254.                 // Panning ranges from 0->64, mapped onto 128->192
  255.  
  256.         if(maskvariable & 8), then read command (byte value) and commandvalue
  257.                 // Valid ranges from 0->31 (0=no effect, 1=A, 2=B, 3=C, etc.)
  258.  
  259.         if(maskvariable & 16), then note = lastnote for channel
  260.         if(maskvariable & 32), then instrument = lastinstrument for channel
  261.         if(maskvariable & 64), then volume/pan = lastvolume/pan for channel
  262.         if(maskvariable & 128), then {
  263.                 command = lastcommand for channel and
  264.                 commandvalue = lastcommandvalue for channel
  265.         }
  266.         Goto GetNextChannelMarker
  267.  
  268.  
  269.  
  270.                                   Mathematics
  271.  
  272. Abbreviations:
  273.  FV = Final Volume (Ranges from 0 to 128). In versions 1.04+, mixed output
  274.       devices are reduced further to a range from 0 to 64 due to lack of
  275.       memory.
  276.  Vol = Volume at which note is to be played. (Ranges from 0 to 64)
  277.  SV = Sample Volume (Ranges from 0 to 64)
  278.  CV = Channel Volume (Ranges from 0 to 64)
  279.  GV = Global Volume (Ranges from 0 to 128)
  280.  VEV = Volume Envelope Value (Ranges from 0 to 64)
  281.  
  282. In Sample mode, the following calculation is done:
  283.  FV = Vol * SV * CV * GV / 262144               ; Note that 262144 = 2^18
  284.                                                 ; So bit shifting can be done.
  285.  
  286. In Instrument mode the following procedure is used:
  287.  
  288.  1) Update volume envelope value. Check for loops / end of envelope.
  289.  2) If end of volume envelope (ie. position >= 200 or VEV = 0FFh), then turn
  290.         on note fade.
  291.  3) If notefade is on, then NoteFadeComponent (NFC) = NFC - FadeOut
  292.         ; NFC should be initialised to 512 when a note is played.
  293.  4) FV = Vol * SV * CV * GV * VEV * NFC / 8589934592
  294.                                                 ; Note that 8589934592 = 2^33
  295.  
  296. Linear slides work like this:
  297.  Final frequency = Original frequency * 2^(SlideValue/768)
  298.  
  299. (I used a lookup table for the multipliers here)
  300.  
  301. For command Exx, SlideValue = -4*EffectValue
  302. For command EEx, SlideValue = -EffectValue
  303. For command Fxx, SlideValue = 4*EffectValue
  304. For command FEx, SlideValue = EffectValue
  305.  
  306. Note that sample vibrato always uses Linear slides.
  307.  
  308. Notes about effects (as compared to other module formats)
  309.  
  310. C               This is now in *HEX*. (Used to be in decimal in ST3)
  311. E/F/G/H/U       You need to check whether the song uses Amiga/Linear slides.
  312. H               Vibrato in Impulse Tracker is two times finer than in
  313.                 any other tracker and is updated EVERY tick.
  314. E/F/G           These commands ALL share the same memory.
  315. Yxy             This uses a table 4 times larger (hence 4 times slower) than
  316.                 vibrato or tremelo. If the waveform is set to random, then
  317.                 the 'speed' part of the command is interpreted as a delay.
  318.  
  319. If you read through this document and there are ANY points which you have
  320. troubles with (and have to try out), then let me know - because someone
  321. else will have the same questions - and I'd like to make this DOC as easy
  322. to understand as possible.
  323.  
  324.                                   General Info
  325.  
  326. The player in Impulse Tracker 'allocates' channels to notes whenever they
  327. are *PLAYED*. In sample mode, the allocation is simple:
  328.                         Virtual Channel = 'Host' channel
  329.  
  330. In instrument mode, the following procedure is used:
  331.  
  332.     Check if channel is already playing ---Yes--> set 'background' flag on.
  333.                 |                                 'Trigger' NNA. If NNA=cut,
  334.                 No                                then use this virtual
  335.                 |                                 channel.
  336.                 |                                          |
  337.                 |<------------------ else -----------------/
  338.                 |
  339.                 v
  340.     Search and find the first non-active virtual channel.
  341.                 |
  342.     Non-active channel found? ----Yes----> Use this for playback.
  343.                 |
  344.                 No
  345.                 |
  346.                 v
  347.    Search through and find the channel of lowest volume that is in the
  348.    'background' (ie. no longer controlled directly)
  349.                 |
  350.    Background channel found? ----Yes----> Use this for playback.
  351.                 |
  352.                 No
  353.                 |
  354.                 v
  355.    Return error - the note is *NOT* allocated a channel, and hence is not
  356.    played.
  357.  
  358.    Actually, this is quite a simple process... just that it's another of
  359.    those 'hassles' to have to write...
  360.